AMD IOV: Fix xen boot on non-iommu systems.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Apr 2008 13:59:25 +0000 (14:59 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Apr 2008 13:59:25 +0000 (14:59 +0100)
Signed-off-by: Wei Wang <wei.wang2@amd.com>
xen/drivers/passthrough/amd/iommu_detect.c

index 68d04a66a28fc2e7ff871dfe4ae8049f797bd4c0..d3b51b9830a4e4b5ff94dfd3863a47c25867965c 100644 (file)
@@ -216,24 +216,24 @@ static int __init scan_functions_for_iommu(
     int bus, int dev, iommu_detect_callback_ptr_t iommu_detect_callback)
 {
     int func, hdr_type;
-    int count, error = 0;
+    int count = 1, error = 0;
+
+    for ( func = 0;
+          (func < count) && !error &&
+              VALID_PCI_VENDOR_ID(pci_conf_read16(bus, dev, func,
+                                                  PCI_VENDOR_ID));
+          func++ )
 
-    func = 0;
-    count = 1;
-    while ( VALID_PCI_VENDOR_ID(pci_conf_read16(bus, dev, func,
-                                                PCI_VENDOR_ID)) &&
-            !error && (func < count) )
     {
         hdr_type = pci_conf_read8(bus, dev, func, PCI_HEADER_TYPE);
 
-        if ( func == 0 && IS_PCI_MULTI_FUNCTION(hdr_type) )
+        if ( (func == 0) && IS_PCI_MULTI_FUNCTION(hdr_type) )
             count = PCI_MAX_FUNC_COUNT;
 
         if ( IS_PCI_TYPE0_HEADER(hdr_type) ||
              IS_PCI_TYPE1_HEADER(hdr_type) )
             error = scan_caps_for_iommu(bus, dev, func,
                                         iommu_detect_callback);
-        func++;
     }
 
     return error;